package api

import (
	"2301a/awesomezouProjectye4/api/handler"
	"2301a/awesomezouProjectye4/consts"
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
)

func LoadRouter(r *gin.Engine) {

	api := r.Group("api")
	{
		user := api.Group("user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)
		}
		goods := api.Group("goods")
		{
			goods.Use(jwt.JWTAuth(consts.JWT_KEY))
			goods.POST("/add", handler.AddGoods)         //添加商品
			goods.POST("/modify", handler.ModifyGoods)   //修改商品
			goods.POST("/list", handler.ListGoods)       //列表商品
			goods.POST("/page", handler.PageGoods)       //分页
			goods.POST("/collect", handler.CollectGoods) //收藏商品
			goods.POST("/details", handler.DetailsGoods) //详情商品
			goods.POST("/remove", handler.RemoveGoods)   //删除商品
		}
		comment := api.Group("comment")
		{
			comment.Use(jwt.JWTAuth(consts.JWT_KEY))
			comment.POST("/release", handler.ReleaseComment) //添加评论
			comment.POST("/list", handler.ListComment)       //列表评论
			comment.POST("/details", handler.DetailsComment) //详情评论
			comment.POST("/remove", handler.RemoveComment)   //删除评论
		}
	}

}
